import OctreeCSG from './OctreeCSG/OctreeCSG'
/**
 * @description: 构造立体几何
 * @param {THREE.Mesh} mesh1
 * @param {THREE.Mesh} mesh2
 * @param {csgOperationsType} operation "union" | "subtract" | "intersect"
 * @return {THREE.BufferGeometry}
 */
export function ConstructiveSolidGeometry(mesh1, mesh2, operation) {
  const mesh1Octree = OctreeCSG.fromMesh(mesh1)
  const mesh2Octree = OctreeCSG.fromMesh(mesh2)
  const resultOctree = OctreeCSG[operation](mesh1Octree.clone(), mesh2Octree.clone(), false)
  const resultGeom = OctreeCSG.toGeometry(resultOctree)
  return resultGeom
}
